import { RouteRecordRaw } from 'vue-router'
import Layout from '@/layout/index.vue'

import Home from '../views/home/index.vue'
import FormView from '../views/form/index.vue'

import { FlowPost } from '@/api/flow'

export const createRoute = (item: FlowPost): RouteRecordRaw => {
  return {
    path: `/${item.name}`,
    component: Layout,
    children: [
      {
        path: '',
        name: item.name,
        component: FormView,
        meta: {
          title: item.title,
          icon: 'el-icon-postcard',
          arguments: item.arguments
        }
      }
    ]
  }
}
const createStaticRoutes = (): Array<RouteRecordRaw> => {
  return [
    {
      path: '/',
      component: Home,
      name: 'home',
      meta: { title: '首页', icon: 'el-icon-discover' }
    }
  ]
}

export default createStaticRoutes
